package com.gopay.bis.ccb.ebank.impl;



import com.gopay.bis.ccb.ebank.operation.B2cSocketTransportImpl;
import com.gopay.bis.ccb.ebank.operation.CcbB2cBuildMessage;
import com.gopay.bis.ccb.ebank.operation.CcbB2cParseMessage;
import com.gopay.common.domain.bank.BaseMessage;
import com.gopay.common.domain.bank.ccb.ebank.pay.CcbB2cMessage;
import com.gopay.common.exception.GopayException;
import com.gopay.remote.bank.ICertHelper;
import com.gopay.remote.bank.businesses.BankService;

/**
 * 建行B2C请求接口
 * 
 * @CcbB2cBankServiceImpl.java
 * @author WangHongFei
 */
public class CcbB2cBankServiceImpl implements BankService {
	private B2cSocketTransportImpl b2cSocketTransportImpl;
	private CcbB2cBuildMessage ccbB2cBuildMessage;
	private CcbB2cParseMessage ccbB2cParseMessage;
    private ICertHelper ccbB2cCerthelper;
    public String sign(BaseMessage message) throws GopayException{
        String signMsg = "";
        signMsg = ccbB2cCerthelper.sign(message);
        return signMsg;
    }

    public Object verify(BaseMessage message) throws GopayException{    	
        boolean verifyResult = false;
        verifyResult = (Boolean) ccbB2cCerthelper.verify(message);
        return verifyResult;

    }

    public Object query(Object object) throws GopayException{
    	CcbB2cMessage CcbB2cMessage = (CcbB2cMessage) object;
        String bulidMsg = ccbB2cBuildMessage.buildB2cXmlStr(CcbB2cMessage);// 构建xml
        Object obj = this.b2cSocketTransportImpl.submit(bulidMsg); // 发送银行
        CcbB2cMessage retMsg = ccbB2cParseMessage.parseB2cXml(obj);// 解析银行返回参数
        return retMsg;
    }

	public void setB2cSocketTransportImpl(
			B2cSocketTransportImpl b2cSocketTransportImpl) {
		this.b2cSocketTransportImpl = b2cSocketTransportImpl;
	}

	public void setCcbB2cBuildMessage(CcbB2cBuildMessage ccbB2cBuildMessage) {
		this.ccbB2cBuildMessage = ccbB2cBuildMessage;
	}

	public void setCcbB2cParseMessage(CcbB2cParseMessage ccbB2cParseMessage) {
		this.ccbB2cParseMessage = ccbB2cParseMessage;
	}

	public void setCcbB2cCerthelper(ICertHelper ccbB2cCerthelper) {
		this.ccbB2cCerthelper = ccbB2cCerthelper;
	}

	@Override
	public Object dayend(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Object refund(Object obj) throws GopayException {
		// TODO Auto-generated method stub
		return null;
	}

}
